home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_096 / warptext / warp.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  5KB  |  136 lines

  1. /* WarpText Quickie Test    Anson Mah  06/08/87
  2.  * For Lattice C
  3.  *
  4.  * NOTE: This test does not use any of the WarpText 2.0 routines as
  5.  *       they did not exist when Anson wrote this.
  6.  *       I made an example program for all of the routines but I
  7.  *       couldn't get the $#%! assembler to assembler it!  It kept
  8.  *       giving me all sorts of strange errors on the second pass.
  9.  *       I was able to test all the routines interactively in Forth
  10.  *       so, while I know the new (and old) routines work, I have no
  11.  *       program to give out that demonstrates them...  Sorry,
  12.  *                                                      Bill.
  13.  */
  14.  
  15. #include <exec/types.h>
  16. #include <exec/memory.h>
  17. #include <intuition/intuition.h>
  18. #include "graphics/WarpText.h"
  19.  
  20. extern void InitWarpInfo(), GotoXY(), GetXY(), WarpText();
  21.  
  22. struct IntuitionBase *IntuitionBase;
  23. struct GfxBase *GfxBase = NULL;
  24. struct Window *w = NULL;
  25. struct WarpInfo *winfo = NULL;
  26.  
  27. struct TextAttr taTopaz80 = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT };
  28.  
  29. struct NewWindow wdef = {
  30.         0,0,640,200,
  31.         0,1,
  32.         CLOSEWINDOW,
  33.         WINDOWDRAG | WINDOWCLOSE | WINDOWDEPTH | SMART_REFRESH | ACTIVATE,
  34.         NULL, NULL,
  35.         "WarpText Test",
  36.         NULL, NULL,
  37.         0,0,640,200,
  38.         WBENCHSCREEN
  39. };
  40.  
  41. void closestuff()
  42. {
  43.         if (winfo)              FreeMem(winfo, sizeof(struct WarpInfo));
  44.         if (w)                  CloseWindow(w);
  45.         if (GfxBase)            CloseLibrary(GfxBase);
  46.         if (IntuitionBase)      CloseLibrary(IntuitionBase);
  47.         XCEXIT(0);
  48. }
  49.  
  50. void openstuff()
  51. {
  52.         if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary(
  53.                 "intuition.library", 33)))
  54.                 closestuff();
  55.         if (!(GfxBase = (struct GfxBase *)OpenLibrary(
  56.                 "graphics.library", 33)))
  57.                 closestuff();
  58.         if (!(winfo = (struct WarpInfo *)AllocMem(sizeof(struct WarpInfo),
  59.                 MEMF_PUBLIC)))
  60.                 closestuff();
  61.         if (!(w = (struct Window *)OpenWindow(&wdef)))
  62.                 closestuff();
  63. }
  64.  
  65. ULONG strlen(s)
  66. char *s;
  67. {
  68.         ULONG i = 0;
  69.  
  70.         while (*s++)
  71.                 i++;
  72.         return(i);
  73. }
  74.  
  75. void _main()
  76. {
  77.         static char *text[17];
  78.         struct IntuiMessage *msg;
  79.         ULONG class;
  80.         UWORD i;
  81.  
  82.         openstuff();
  83.  
  84.         text[0] = "Hi, Bill!\n";
  85.         text[1] = "   Thanx for your WarpText routines.  As you can see, this\n";
  86.         text[2] = "is a quick test of 'em.  The only routine I don't use is\n";
  87.         text[3] = "GetXY.  Also note that I have created a WarpText.h file for\n";
  88.         text[4] = "C programmers like yours truly and also a C interface\n";
  89.         text[5] = "module for the same people!  Please do what you will with\n";
  90.         text[6] = "them.\n";
  91.         text[7] = "   Right.  I've looked over your code and can't see any\n";
  92.         text[8] = "immediate improvements, but I may if I study them longer.\n";
  93.         text[9] = "Actually, I believe you might gain some more speed if you\n";
  94.         text[10] = "start using the Blitter instead.  It was made to handle\n";
  95.         text[11] = "stuff like this.  You should be able to get upward of\n";
  96.         text[12] = "30,000 chars/sec if you use it.  This number was measured\n";
  97.         text[13] = "with the set of routines my friends came up with a while\n";
  98.         text[14] = "back.  It's fairly accurate.\n";
  99.         text[15] = "   Anyway, more when I have more time to hack!\n";
  100.         text[16] = "                                          Anson";
  101.  
  102.         /* set up WarpInfo */
  103.         winfo->wi_TextFont = (APTR)OpenFont(&taTopaz80);
  104.         winfo->wi_BitMap = (APTR)&w->WScreen->BitMap;
  105.         winfo->wi_WhichPlane = 0;
  106.         winfo->wi_Left = 10;
  107.         winfo->wi_Top = 3;
  108.         winfo->wi_Width = 60;
  109.         winfo->wi_Height = 21;
  110.         InitWarpInfo(winfo);
  111.  
  112.         /* warp out text */
  113.         for (i = 0; i < 17; i++)
  114.                 WarpText(winfo, text[i], strlen(text[i]));
  115.         GotoXY(winfo, 25, 19);
  116.         WarpText(winfo, "Hey, I'm here!", 14);
  117.         GotoXY(winfo, 10, 20);
  118.         WarpText(winfo, "And here!!", 10);
  119.  
  120.         CloseFont(winfo->wi_TextFont);
  121.  
  122.         for (;;) {
  123.                 WaitPort(w->UserPort);
  124.                 msg = (struct IntuiMessage *)GetMsg(w->UserPort);
  125.                 ReplyMsg(msg);
  126.                 class = msg->Class;
  127.                 switch (class) {
  128.                         case CLOSEWINDOW:
  129.                                 closestuff();
  130.                                 break;
  131.                 }
  132.         }
  133. }
  134.  
  135. void MemCleanup() {}  /* Lattice stub */
  136.